package com.itheima.reggie.utils;

/**
 * 用户信息保存线程局部变量
 * 基于ThreadLocal封装工具类，用户保存和获取当前登录用户id
 *
 * @author Upjqs
 * @since 2024-01-29 14:53
 */
public class LoginThreadLocal {
    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();


    /**
     * 获取当前
     *
     * @return
     */
    public static Long getCurrent() {
        return threadLocal.get();
    }

    /**
     * 赋值当前
     *
     * @param value
     */
    public static void setCurrent(Long value) {
        threadLocal.set(value);
    }

    /**
     * 清除变量
     */
    public static void remove() {
        threadLocal.remove();
    }
}
